<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
    </head>
    <body>
        <script>
            const p =new Promise((resolve,reject)=>{
                    let xhr = new XMLHttpRequest();

                    xhr.open("GET", "https://api.apiopen.top/getJoke");

                    xhr.send();

                    xhr.onreadystatechange = () => {
                        if (xhr.readyState === 4) {
                            if (xhr.status >= 200 && xhr.status < 300) {
                                resolve(xhr.response);
                            } else {
                                reject(xhr.status);
                            };
                        };
                    };
            });
            p.then((value)=>{
                let obj = JSON.parse(value);
                console.log(obj.result[2]);
                // let img = document.createComment("img");
                // img.src = obj.result[2].images;
                // document.body.appendChild(img);
            },(reason)=>{
                console.error(reason);
            });
            
        </script>
    </body>
</html>